package com.prj.util;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.data.Tables;
import com.deepoove.poi.data.style.BorderStyle;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.io.FileUtil;


public class Test {
	
	
	public static void main(String[] args) throws Exception {
		
		String dir = "C:\\Users\\keven\\Desktop\\";
		
		List<Map<String, Object>> songs = new ArrayList<Map<String, Object>>();
		
		for(int i = 0; i < 5; i++) {
			HashMap<String, Object> hashMap = new HashMap<String, Object>();
			hashMap.put("title", "A"+i);
			hashMap.put("title2", "B"+i);
			hashMap.put("title3", "C"+i);
			hashMap.put("table", Tables.of(new String[][] {
                new String[] { "00", "01" },
                new String[] { "10", "11" }
            }).border(BorderStyle.DEFAULT).create());
			songs.add(hashMap);
		}
		
		
		XWPFTemplate template = XWPFTemplate.compile(dir + "mb.docx")
				.render(new HashMap() {{
					put("songs", songs);
				}});
		template.writeAndClose(new FileOutputStream(dir + "output.docx"));
		
		
	}
	
	public static void listFiles(String path, List<File> list) {
		File file = new File(path);
		File[] files = file.listFiles();
	    if(files!=null) {
	    	for(File f : files) {
	    		if(f.isFile() && f.getName().contains("gcc")) {
	    			list.add(f);
	    		}else {
	    			listFiles(f.getAbsolutePath(), list);
	    		}
	    	}
	    }
			
	}

}
